A portion of the disclosure of this patent document may contain material that is subject to copyright protection. The copyright owner has no objection to the facsimile reproduction by anyone of the patent document or the patent disclosure, as it appears in the Patent and Trademark Office patent files or records, but otherwise reserves all copyright rights whatsoever. The following notice shall apply to this document: Copyright(copyright) 2000, Microsoft, Inc.
1. Field of the Invention
The invention relates generally to electronic databases. More particularly, the invention relates to querying of relational databases.
2. Background
Database systems interact with users and applications to provide them with access to data contained in data tables. Traditionally, database systems have used a two-tier architecture to provide this access. In a two-tier architecture, the user or application, known as a client, issues a query to a server on which the data tables reside. The server then returns the requested data to the client. Thus, in a system employing a two-tier architecture, applications directly access the data tables. In order to access the data tables effectively, applications must be programmed with knowledge of the structure of the database. Further, all data validation rules must be programmed into each application that uses the database.
Changing the database structure or the data validation rules governing the database pose a particular challenge to database systems that use a two-tier architecture. In particular, any time a change is made to the structure of the data in the database, the knowledge programmed into all the applications accessing the database is no longer valid. Also, whenever a validation rule is changed, all the applications that access the database have to be updated to reflect the change. To address this problem, alternative architectures have been proposed.
One such architecture is the three-tier database. In a three-tier database, the database and applications layers are present, just as in the two-tier architecture. In addition, however, a data layer is conceptually interposed between these layers, forming a third tier. In the three-tier architecture, all applications access the database through the data layer, rather than directly, as in the two-tier architecture. The data layer provides all of the access methods to query and update the underlying tables. A number of benefits result from using the data layer as an interface between the database and the applications. One major benefit is that structural and locational changes can be made to the database without necessarily requiring changes to all of the applications. Further, all data validation and security is handled by the data layer, making it easier to implement changes in the database.
Although three-tier databases do address several issues concerning two-tier databases, certain issues still remain to be adequately addressed. For example, multi-tier relational databases have generally lacked methods of querying relational data objects.
Various implementations of the present invention facilitate accessing data in a relational database by providing data objects known as query objects and further providing query operators that users can employ to work with the query objects. These data objects encapsulate knowledge of the relationships between tables in the database and reside in the data layer. The query operators define operations on the query objects, including such operations as union, intersection, and intersection-complement operations. According to various implementations of the invention, new query objects are constructed based on constituent query objects and the query operators by which they are related. By using query objects and query operators, users can query a relational database without knowledge of query languages and without knowledge of the relationships between the underlying data tables in the database.
According to one particular implementation of the present invention, selected information is retrieved from an electronic database by constructing first and second query objects. A third query object is then constructed as a function of at least one clause object of the first and second query objects and a query operator. Next, a query string is generated as a function of the third query object and is submitted to the electronic database. The electronic database presents the selected information in response to the query string.
In another implementation, each of the first and second query objects has clause objects and a base object type. The third query object has the same base object type as the first query object, and is formed by adding a first clause group of the clause objects of the first query object and a second clause group of the clause objects of the second query object. The first and second clause groups are separated by a clause operator determined as a function of a query operator. The third query object is used to build a query string that is submitted to the electronic database. The electronic database presents selected information in response to the query string.
Still another implementation is directed to a computer arrangement. A query object has clause objects generated as a function of sets of clause objects contained in two operand query objects and a query operator. A clause processor module generates a query string as a function of the clause objects and submits the query string to a database server storing data tables. The database server returns data from its data tables in response to the query string.
Yet another implementation of the present invention is directed to a storage medium that stores a query object construction module that receives sets of clause objects from two query objects and a query operator and constructs a third query object as a function of the received clause objects and the query operator. The storage medium further stores a query string generator module that generates a query string as a function of the third query object and submits it to an electronic database. The electronic database presents information selected in response to the query string.
In another particular implementation, a data structure stored on a storage medium includes a clause collection having clause objects generated as a function of two sets of clause objects and a query operator. A clause processor module generates a query string as a function of the plurality of clause objects and submits the query string to a database server, which returns information selected as a function of the query string.
Still other implementations include computer-readable media and apparatuses for performing these methods. The above summary of the present invention is not intended to describe every implementation of the present invention. The figures and the detailed description that follow more particularly exemplify these implementations.